// To parse this JSON data, do
//
//     final lineListModel = lineListModelFromJson(jsonString);

import 'dart:convert';

List<LineListModel> lineListModelFromJson(String str) =>
    List<LineListModel>.from(
        json.decode(str).map((x) => LineListModel.fromJson(x)));

String lineListModelToJson(List<LineListModel> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class LineListModel {
  LineListModel({
    required this.meta,
    required this.list,
  });

  Meta meta;
  List<ListElement> list;

  factory LineListModel.fromJson(Map<String, dynamic> json) => LineListModel(
        meta: Meta.fromJson(json["meta"]),
        list: List<ListElement>.from(
            json["list"].map((x) => ListElement.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "meta": meta.toJson(),
        "list": List<dynamic>.from(list.map((x) => x.toJson())),
      };
}

class ListElement {
  ListElement({
    required this.id,
    required this.caption,
    required this.logo,
    required this.startProvinceName,
    required this.startCityName,
    required this.endProvinceName,
    required this.endCityName,
    required this.vip,
    required this.totalDay,
    required this.tag,
    required this.score,
    required this.fav,
    required this.extra,
    required this.sceneCity,
    required this.clickNum,
    required this.totalDistance,
  });

  int id;
  String caption;
  String logo;
  String startProvinceName;
  String startCityName;
  String endProvinceName;
  String endCityName;
  bool vip;
  int totalDay;
  List<String>? tag;
  double score;
  bool fav;
  Extra? extra;
  List<String>? sceneCity;
  int clickNum;
  var totalDistance;

  factory ListElement.fromJson(Map<String, dynamic> json) => ListElement(
        id: json["id"],
        totalDistance:json["totalDistance"] == null? "":json["totalDistance"],
        caption: json["caption"],
        logo: json["logo"],
        startProvinceName: json["startProvinceName"],
        startCityName: json["startCityName"],
        endProvinceName: json["endProvinceName"],
        endCityName: json["endCityName"],
        vip: json["vip"],
        totalDay: json["totalDay"],
        tag:json["tag"] == null?null: List<String>.from(json["tag"].map((x) => x)),
        score: (() {
          double? number = double.tryParse("${json["score"]}");
          if (number == null || number.isNaN) {
            return 0.0;
          }
          return number;
        })(),
        fav:json["fav"] ?? false,
        extra:json["extra"] == null?null: Extra.fromJson(json["extra"]),
        sceneCity:json["sceneCity"] == null?null:   List<String>.from(json["sceneCity"].map((x) => x)),
        clickNum: json["clickNum"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "totalDistance": totalDistance,
        "caption": caption,
        "logo": logo,
        "startProvinceName": startProvinceName,
        "startCityName": startCityName,
        "endProvinceName": endProvinceName,
        "endCityName": endCityName,
        "vip": vip,
        "totalDay": totalDay,
        "tag": List<dynamic>.from(tag!.map((x) => x)),
        "score": score,
        "fav": fav,
        "extra": extra!.toJson(),
        "sceneCity": List<dynamic>.from(sceneCity!.map((x) => x)),
        "clickNum": clickNum,
      };
}

class Extra {
  Extra({
    required this.useless,
  });

  int useless;

  factory Extra.fromJson(Map<String, dynamic> json) => Extra(
        useless: json["useless"],
      );

  Map<String, dynamic> toJson() => {
        "useless": useless,
      };
}

class Meta {
  Meta({
    required this.currentPage,
    required this.maxPage,
    required this.itemCount,
    required this.pageSize,
  });

  int currentPage;
  int maxPage;
  int itemCount;
  double pageSize;

  factory Meta.fromJson(Map<String, dynamic> json) => Meta(
        currentPage: json["currentPage"],
        maxPage: json["maxPage"],
        itemCount: json["itemCount"],
        pageSize: json["pageSize"]?.toDouble(),
      );

  Map<String, dynamic> toJson() => {
        "currentPage": currentPage,
        "maxPage": maxPage,
        "itemCount": itemCount,
        "pageSize": pageSize,
      };
}
